home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / SESSION.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  15KB  |  367 lines

  1. ;*********************;
  2. ; SESSION Main Module ;
  3. ;    By Eric Tauck    ;
  4. ;*********************;
  5.  
  6. ;***************************************************************************;
  7. ; SESSION is a fully functional communications program.  This program       ;
  8. ; demonstrates the use of many of the WASM library modules.                 ;
  9. ;                                                                           ;
  10. ; WASM does not allow nested INCLUDE files, thus all the files required by  ;
  11. ; SESSION are included in this, the main, source file.  The library files   ;
  12. ; are assumed to be in the LIBRARY sudirectory of the parent directory      ;
  13. ; (..\LIBRARY).  The other SESSION source files (INCLUDEed at the end of    ;
  14. ; this file) are:                                                           ;
  15. ;                                                                           ;
  16. ;   ANSI.ASM      ANSI terminal support                                     ;
  17. ;   BEEPS.ASM     sound effects                                             ;
  18. ;   COMMAND.ASM   string input and messages                                 ;
  19. ;   DISPLAY.ASM   display output and initialization                         ;
  20. ;   OPTIONS.ASM   command line options                                      ;
  21. ;   MACRO.ASM     macro support                                             ;
  22. ;   TERMINAL.ASM  terminal mode                                             ;
  23. ;   TRANSFER.ASM  file transfer                                             ;
  24. ;                                                                           ;
  25. ; SESSION is assembled with:                                                ;
  26. ;                                                                           ;
  27. ;   WASM session                                                            ;
  28. ;                                                                           ;
  29. ; Once assembled, SESSION is may be run by entering SESSION at the DOS      ;
  30. ; command line.  You are placed in terminal mode connected to serial port   ;
  31. ; one.  Every key you type is sent to the serial port and every character   ;
  32. ; received from the serial port is displayed to the screen.  The keyboard   ;
  33. ; commands to control SESSION are:                                          ;
  34. ;                                                                           ;
  35. ;  Control                      Transfer                                    ;
  36. ;  -------                      --------                                    ;
  37. ;                                                                           ;
  38. ;  ALT-A  abort file transfer   ALT-U  upload text file                     ;
  39. ;  ALT-C  clear screen          ALT-D  download text file                   ;
  40. ;  ALT-M  run macro             PgUp   upload binary file                   ;
  41. ;  ALT-R  reset screen          PgDn   download binary file                 ;
  42. ;  ALT-X  exit program                                                      ;
  43. ;  ALT-Z  system shell                                                      ;
  44. ;                                                                           ;
  45. ;  Configure                                                                ;
  46. ;  ---------                                                                ;
  47. ;                                                                           ;
  48. ;  ALT-E  toggle echo           ALT-B  toggle macro debugging               ;
  49. ;  ALT-S  toggle split screen                                               ;
  50. ;                                                                           ;
  51. ; Future improvements:                                                      ;
  52. ;                                                                           ;
  53. ;   * Trap BREAK to properly terminate the serial port connection           ;
  54. ;   * Trap critical DOS errors for the same reason as above                 ;
  55. ;                                                                           ;
  56. ; Versions changes:                                                         ;
  57. ;                                                                           ;
  58. ;   1.01  Fix ANSI sequences: alternate move is f not F, check for color    ;
  59. ;         out of range, row/column reversed for f and H, and 1J is clear    ;
  60. ;         from curor.                                                       ;
  61. ;                                                                           ;
  62. ;   1.02  Formfeed character clears the window.                             ;
  63. ;***************************************************************************;
  64.  
  65.         JUMP+
  66.         UNUSED+
  67.  
  68. ;--- some standard control characters
  69.  
  70. BEL     EQU     7       ;bell
  71. BS      EQU     8       ;backspace
  72. TAB     EQU     9       ;tab
  73. LF      EQU     10      ;linefeed
  74. FF      EQU     12      ;formfeed
  75. CR      EQU     13      ;carriage return
  76. ;XON    EQU     17      ;DC1, restart flow (not used)
  77. XOFF    EQU     19      ;DC3, stop flow
  78. ESC     EQU     27      ;carriage return
  79.  
  80. ;========================================
  81. ; User configuration.
  82.  
  83. COMM_SIZE       EQU     4096            ;size of communications buffer
  84.  
  85. MACRO_CODESIZE  EQU     4096            ;macro code and return segment size
  86. MACRO_STACKSIZE EQU     4096            ;macro stack segment size
  87. MACRO_SYMSIZE   EQU     2048            ;macro symbol table size
  88.  
  89. TEMP_TIMER      EQU     1               ;general timer for anything
  90. PACE_TIMER      EQU     2               ;timer for pace count
  91. MACRO_TIMER     EQU     3               ;timer for macros
  92.  
  93. ATTR_COUNT      EQU     11              ;number of attributes below
  94.  
  95. ;--- monchrome adapter attributes
  96.  
  97. M_ATTR_INP1     EQU     (WHITE * 16) OR BLACK   ;input
  98. M_ATTR_CONF     EQU     (WHITE * 16) OR BLACK   ;confirm something
  99. M_ATTR_STAT     EQU     (WHITE * 16) OR BLACK   ;top line status
  100. M_ATTR_TERM     EQU     (BLACK * 16) OR WHITE   ;terminal input
  101. M_ATTR_LOC      EQU     (BLACK * 16) OR WHITE   ;local input
  102. M_ATTR_REM      EQU     (BLACK * 16) OR WHITE   ;remote input
  103. M_ATTR_LINE     EQU     (BLACK * 16) OR WHITE   ;center line in split
  104. M_ATTR_HELP     EQU     (BLACK * 16) OR WHITE   ;help text
  105. M_ATTR_ERROR    EQU     (WHITE * 16) OR BLACK   ;error message
  106. M_ATTR_MESS     EQU     (BLACK * 16) OR WHITE   ;system terminal message
  107. M_ATTR_DEBUG    EQU     (BLACK * 16) OR WHITE OR BOLD ;debug terminal message
  108.  
  109. ;--- color adapter attributes
  110.  
  111. C_ATTR_INP1     EQU     (BLUE * 16) OR WHITE    ;input prompt
  112. C_ATTR_CONF     EQU     (RED * 16) OR WHITE     ;confirm something
  113. C_ATTR_STAT     EQU     (WHITE * 16) OR BLUE    ;top line status
  114. C_ATTR_TERM     EQU     (BLACK * 16) OR WHITE   ;terminal input
  115. C_ATTR_LOC      EQU     (BLACK * 16) OR GREEN   ;local input
  116. C_ATTR_REM      EQU     (BLACK * 16) OR WHITE   ;remote input
  117. C_ATTR_LINE     EQU     (BLACK * 16) OR BLUE    ;center line in split
  118. C_ATTR_HELP     EQU     (BLACK * 16) OR WHITE   ;help text
  119. C_ATTR_ERROR    EQU     (RED * 16) OR WHITE     ;error message
  120. C_ATTR_MESS     EQU     (BLACK * 16) OR CYAN    ;system terminal mess
  121. C_ATTR_DEBUG    EQU     (BLACK * 16) OR BROWN   ;debug terminal mess
  122.  
  123. ;========================================
  124. ; Library modules.
  125.  
  126.         UNUSED-
  127.         INCLUDE '..\library\start.asm'
  128.         INCLUDE '..\library\buffer1.asm'
  129.         INCLUDE '..\library\buffer2.asm'
  130.         INCLUDE '..\library\buffer3.asm'
  131.         INCLUDE '..\library\buffer4.asm'
  132.         INCLUDE '..\library\case1.asm'
  133.         INCLUDE '..\library\case2.asm'
  134.         INCLUDE '..\library\check1.asm'
  135.         INCLUDE '..\library\check3.asm'
  136.         INCLUDE '..\library\convert.asm'
  137.         INCLUDE '..\library\enviro.asm'
  138.         INCLUDE '..\library\file.asm'
  139.         INCLUDE '..\library\input.asm'
  140.         INCLUDE '..\library\justify1.asm'
  141.         INCLUDE '..\library\keybrd.asm'
  142.         INCLUDE '..\library\macro1.asm'
  143.         INCLUDE '..\library\macro2.asm'
  144.         INCLUDE '..\library\memory.asm'
  145.         INCLUDE '..\library\message1.asm'
  146.         INCLUDE '..\library\parms.asm'
  147.         INCLUDE '..\library\prompt.asm'
  148.         INCLUDE '..\library\serial1.asm'
  149.         INCLUDE '..\library\serial2.asm'
  150.         INCLUDE '..\library\serial3.asm'
  151.         INCLUDE '..\library\serial4.asm'
  152.         INCLUDE '..\library\serial5.asm'
  153.         INCLUDE '..\library\serial6.asm'
  154.         INCLUDE '..\library\serial7.asm'
  155.         INCLUDE '..\library\serial9.asm'
  156.         INCLUDE '..\library\shell1.asm'
  157.         INCLUDE '..\library\shell2.asm'
  158.         INCLUDE '..\library\sound.asm'
  159.         INCLUDE '..\library\stack.asm'
  160.         INCLUDE '..\library\string.asm'
  161.         INCLUDE '..\library\stringf.asm'
  162.         INCLUDE '..\library\ticks.asm'
  163.         INCLUDE '..\library\video1.asm'
  164.         INCLUDE '..\library\video2.asm'
  165.         INCLUDE '..\library\video3.asm'
  166.         INCLUDE '..\library\video4.asm'
  167.         INCLUDE '..\library\video5.asm'
  168.         INCLUDE '..\library\video6.asm'
  169.         INCLUDE '..\library\video7.asm'
  170.         INCLUDE '..\library\video8.asm'
  171.         INCLUDE '..\library\video9.asm'
  172.         INCLUDE '..\library\xmodem1.asm'
  173.         INCLUDE '..\library\xmodem2.asm'
  174.         UNUSED+
  175.  
  176. ;========================================
  177. ; Program entry point.
  178.  
  179.         mov     MacBug, 1       ;enable macro debugging
  180.         call    Get_Options     ;process command line arguments
  181.         mov     si, ax          ;save macro file
  182.  
  183. ;--- allocate communications buffer
  184.  
  185.         mov     di, OFFSET srec ;serial port record address
  186.         mov     ax, COMM_SIZE   ;byte for communications buffer
  187.         mov     bx, di
  188.         call    ComAll          ;allocate buffer
  189.         jc      error1
  190.  
  191. ;--- allocate macro buffer
  192.  
  193.         mov     ax, MACRO_CODESIZE
  194.         mov     bx, MACRO_STACKSIZE
  195.         mov     cx, MACRO_SYMSIZE
  196.         call    MacAll          ;allocate buffers
  197.         jc      error1
  198.  
  199. ;--- initialize display
  200.  
  201.         call    Display_Init    ;initialize display
  202.  
  203. ;--- enter terminal mode
  204.  
  205.         mov     ax, si
  206.         call    Terminal        ;do terminal mode
  207.  
  208. ;--- finished
  209.  
  210.         call    MacRel          ;release macro buffers
  211.         mov     bx, di
  212.         call    ComRel          ;release communications buffer
  213.         call    Display_Done    ;terminate display
  214.         mov     ax, 4C00H       ;terminate function
  215.         int     21H             ;execute
  216.  
  217. ;--- errors
  218.  
  219. error1  mov     ax, OFFSET mes1 ;error message
  220.  
  221. error2  call    MesPutL         ;display message (note: global entry point)
  222.         mov     ax, 4CFFH       ;terminate function
  223.         int     21H             ;execute
  224.  
  225. ;========================================
  226. ; Declarations.
  227.  
  228. ;--- other SESSION modules.
  229.  
  230.         INCLUDE 'ansi.asm'
  231.         INCLUDE 'beeps.asm'
  232.         INCLUDE 'command.asm'
  233.         INCLUDE 'debug.asm'
  234.         INCLUDE 'macro.asm'
  235.         INCLUDE 'options.asm'
  236.         INCLUDE 'display.asm'
  237.         INCLUDE 'terminal.asm'
  238.         INCLUDE 'transfer.asm'
  239.  
  240. ;--- initialized data
  241.  
  242. banner  DB      '* Session Version 1.02',13,10,0
  243. mes1    DB      'Not enough memory',0
  244.  
  245. pacetime DW     9               ;1/2 second pacing for text uploads
  246.  
  247. ;--- communication parameters, must be word value for OPTIONS.ASM
  248.  
  249. c_port  DW      1               ;port
  250. c_party DW      PARITY_NONE     ;parity
  251. c_data  DW      8               ;data bits
  252. c_stop  DW      1               ;stop bits
  253. c_speed DW      2400            ;speed
  254.  
  255. ;--- attribute arrays
  256.  
  257. attr_bw  DB     M_ATTR_INP1, M_ATTR_CONF, M_ATTR_STAT, M_ATTR_TERM
  258.          DB     M_ATTR_LOC, M_ATTR_REM, M_ATTR_LINE, M_ATTR_HELP
  259.          DB     M_ATTR_ERROR, M_ATTR_MESS, M_ATTR_DEBUG
  260.  
  261. attr_col DB     C_ATTR_INP1, C_ATTR_CONF, C_ATTR_STAT, C_ATTR_TERM
  262.          DB     C_ATTR_LOC, C_ATTR_REM, C_ATTR_LINE, C_ATTR_HELP
  263.          DB     C_ATTR_ERROR, C_ATTR_MESS, C_ATTR_DEBUG
  264.  
  265. ;========================================
  266. ; Uninitialized data.
  267.  
  268. srec    ORG     +SERIAL_RECORD  ;serial record
  269.  
  270. ;=== colors
  271.  
  272. attr_start      LABEL   BYTE
  273.  
  274. attr_inp1       LABEL   BYTE
  275.                 ORG     +1
  276. attr_conf       LABEL   BYTE
  277.                 ORG     +1
  278. attr_stat       LABEL   BYTE
  279.                 ORG     +1
  280. attr_term       LABEL   BYTE
  281.                 ORG     +1
  282. attr_loc        LABEL   BYTE
  283.                 ORG     +1
  284. attr_rem        LABEL   BYTE
  285.                 ORG     +1
  286. attr_line       LABEL   BYTE
  287.                 ORG     +1
  288. attr_help       LABEL   BYTE
  289.                 ORG     +1
  290. attr_error      LABEL   BYTE
  291.                 ORG     +1
  292. attr_mess       LABEL   BYTE
  293.                 ORG     +1
  294. attr_debug      LABEL   BYTE
  295.                 ORG     +1
  296.  
  297. ;=== ANSI.ASM
  298.  
  299. a_MAX   EQU     10 + 1  ;maximum ANSI arguments (need one extra)
  300.  
  301. a_tab   LABEL   BYTE    ;ANSI sequence argument table
  302.         ORG     +a_MAX
  303.  
  304. a_cnt   LABEL   WORD
  305.         ORG     +2      ;number of arguments defined
  306.  
  307. ;=== COMMAND.ASM
  308.  
  309. c_sav1  LABEL   WORD    ;saved cursor location
  310.         ORG     +2
  311. c_sav2  LABEL   BYTE    ;saved cursor state
  312.         ORG     +1
  313.  
  314. s_sav   LABEL   WORD    ;screen save location
  315.         ORG     +2
  316. s_loc1  LABEL   WORD    ;upper left location
  317.         ORG     +2
  318. s_loc2  LABEL   WORD    ;lower right location
  319.         ORG     +2
  320.  
  321. ;=== DISPLAY.ASM
  322.  
  323. cols    LABEL   BYTE    ;screen columns
  324.         ORG     +1
  325. rows    LABEL   BYTE    ;screen rows
  326.         ORG     +1
  327. sattr   LABEL   BYTE    ;save attribute
  328.         ORG     +1
  329.  
  330. window1 LABEL   BYTE    ;terminal window
  331.         ORG     +W_SIZE
  332. window2 LABEL   BYTE    ;local input window
  333.         ORG     +W_SIZE
  334. window3 LABEL   BYTE    ;remote input window
  335.         ORG     +W_SIZE
  336.  
  337. loc_win LABEL   WORD    ;pointer to local window
  338.         ORG     +2
  339. rem_win LABEL   WORD    ;pointer to remote window
  340.         ORG     +2
  341. s_col   LABEL   BYTE    ;cursor column
  342.         ORG     +1
  343. ;s_row  LABEL   BYTE    ;cursor row (loaded as word with s_col)
  344.         ORG     +1
  345. s_seg   LABEL   WORD    ;save data segment
  346.         ORG     +2
  347.  
  348. ;=== TERMINAL.ASM
  349.  
  350. t_ser   LABEL   WORD    ;terminal serial record address
  351.         ORG     +2
  352. t_cbyt  LABEL   BYTE    ;remote byte for terminal
  353.         ORG     +1
  354. t_kbyt  LABEL   WORD    ;local byte for terminal (actually keystroke word)
  355.         ORG     +2
  356.  
  357. ;=== TRANSFER.ASM
  358.  
  359. t_rec   ORG     +BUFFER_RECORD  ;text buffer record (TRANSFER.ASM)
  360.  
  361. t_cur   LABEL   WORD    ;current characters in write line
  362.         ORG     +2
  363. t_lin   LABEL   DWORD   ;write line buffer address
  364.         ORG     +4
  365. x_prom  LABEL   WORD    ;xmodem upload/download prompt
  366.         ORG     +2
  367.